package com.chinadci.smartcommunitysystembackstage.controller;

import com.chinadci.smartcommunitysystembackstage.util.FileUploadUtil;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
@CrossOrigin
@Api("建业E家")
public class Scsuploadimg {

    @RequestMapping(value = "/uploadImg")
    @ResponseBody
    public   Map<String,Object> uploadImg(MultipartFile file, HttpServletRequest request){
        Map<String,Object> data  = new HashMap<>();
        String url = "";
        if (!file.isEmpty()){
            url = FileUploadUtil.saveImage(file,"orderVoucher",request);
        }
        data.put("url",url);
        return data;
    }
}
